/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.isd.inventario.dao;

import java.util.List;
import javax.ejb.Stateless;
import javax.ejb.LocalBean;
import javax.persistence.Query;
import com.isd.global.dao.BaseDAO;
import com.isd.global.web.MailFactory;
import com.isd.inventario.modelo.TipoProducto;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * @author ctrosch
 */
@Stateless
@LocalBean
public class TipoProductoDAO extends BaseDAO {

    public List<TipoProducto> getLista(){
        
        try {
            Query q = (Query) getEntityManager().createQuery("SELECT object(o) FROM TipoProducto as o "
                    + "WHERE o.stocks = 'S' "
                    + "AND o.tippro >='000' "
                    + "AND o.tippro <='998' "
                    + "AND o.debaja = 'N' "
                    + "ORDER BY o.descrp");
            return q.getResultList();
        }catch(Exception e){            
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "getLista", e);
            return null;
        }
    }

    public TipoProducto getTipoProducto(String id) {
        try {            
            return getEntityManager().find(TipoProducto.class,id);
        }catch (Exception e){
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "getTipoProducto", e);
            return null;
        }
    }

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
 
}
